package cc.openhome;

/**
 * Created by LJY on 2017/3/31.
 */
public class Hare implements Runnable {
    private boolean[] flags={true,false};
    private int totalStep;
    private int step;
    public Hare(int totalStep){
        this.totalStep=totalStep;
    }
    @Override
    public void run(){
        while (step<totalStep){
            boolean isHareSleep=flags[(int) (Math.random()*10)%2];
            if(isHareSleep){
                System.out.println("兔子睡着了");
            }
            else{
                step+=2;
                System.out.printf("兔子跑了 %d步%n",step);
            }
        }
    }
}
